Record constructors are lists of values that you can use to
initialize a record.
Syntax:
[[data-type]] [ [[{{component},... : component-value};... ]]
[[{CASE [[tag-identifier :]] tag-value OF
[{{component},... : component-value};... ]
OTHERWISE ZERO [[;]] }]] ]
The 'data_type' specifies the constructor's data type. If you
use the constructor in the executable section or in the CONST
section, a data-type identifier is required. Do not use a type
identifier in initial-state specifiers elsewhere in the
declaration section or in nested constructors.
The 'component' specifies a field in the fixed-part of the
record. Fields in the constructor do not have to appear in the
same order as they do in the type definition. (If you choose,
you can specify fields from the variant-part as long as the
fields do not overlap.)
The 'component-value' specifies a value same data type as the
component. These values are compile-time values; if you use the
constructor in the executable section, you can also use run-time
values.
'CASE' provides a constructor for the variant portion of a
record. If the record contains a variant, its constructor must
be the last component in the constructor list.
The 'tag-identifier' specifies the tag-identifier of the variant
portion of the record. This is only required if the variant
part contained a tag-identifier.
The 'tag-value' determines which component list is applicable
according to the variant portion of the record.
'OTHERWISE ZERO' sets all remaining components to their binary
zero value. If you use OTHERWISE ZERO, it must be the last
component in the constructor.
When you specify constructors for a record that contains nested
records, specify the type of the outermost record, but do not
specify the type of the constructors for any nested records.
The following are examples of record variables and possible
standard record constructors:
Example:
TYPE
Player_Rec = RECORD
Wins : INTEGER;
Losses : INTEGER;
Percentage : REAL;
END;
VAR
Player1 : Player_Rec VALUE [Wins: 18; Losses: 3;
Percentage: 21/18]
This record constructor appears in the variable declaration
section, so the constructor type is optional, and compile-time
values are required.
Example:
TYPE
Player_Rec = RECORD
Wins : INTEGER;
Losses : INTEGER;
Percentage : REAL;
END;
VAR
Player1, Player2 : Player_Rec;
{In the executable section}
Player1 := Player_Rec[Wins:18; Losses: y; Percentage: Y+18/18];
This record constructor appears in the executable section, so
the constructor type is required and run-time expressions are
legal.